package com.xiaoai.io.bio6_chat_demo;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 *
 * @Author
 * @Date 2021-09-06 22:31
 */
public class Client {

    public static void main(String[] args){
        try {
            Socket socket = new Socket("127.0.0.1", 8888);
            while (true){
                BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                String msg;
                while ((msg = br.readLine()) != null){
                    System.out.println("客户端收到msg：\n"+msg);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
